package mx.com.initzero.ecommerce.dao.impl;

import java.util.HashMap;
import java.util.Map;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.PreparedStatementCreator;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper;
import org.springframework.jdbc.core.simple.SimpleJdbcInsert;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import org.springframework.jdbc.support.GeneratedKeyHolder;
import org.springframework.jdbc.support.KeyHolder;
import org.springframework.stereotype.Repository;

import com.mysql.jdbc.Connection;
import com.mysql.jdbc.PreparedStatement;
import com.mysql.jdbc.Statement;

import mx.com.initzero.ecommerce.dao.UsuarioCorreoDao;
import mx.com.initzero.ecommerce.dto.UsuarioCorreo;

@Repository
public class UsuarioCorreoDaoImpl extends JdbcDaoSupport implements UsuarioCorreoDao{

	private NamedParameterJdbcTemplate namedParameterJdbcTemplate;

	@Autowired
	public UsuarioCorreoDaoImpl(DataSource dataSource) {
		namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
		setDataSource(dataSource);
		JdbcTemplate jdbcTemplate = new JdbcTemplate();
        jdbcTemplate.setDataSource(dataSource); 
	}
	
	@Override
	public void insertCorreo(UsuarioCorreo usuarioCorreo) {
		// TODO Auto-generated method stub
		SimpleJdbcInsert insert=new SimpleJdbcInsert(getDataSource());
		insert.withTableName("usuariocorreo");
				
		SqlParameterSource parameterSource=new BeanPropertySqlParameterSource(usuarioCorreo);
		insert.execute(parameterSource);
	}

	

}
